{% extends "master.html" %}
{% block title %}Admin{% endblock %}
{% block script %}
<script type="text/javascript">
function saveProfession()
{
	document.forms['profession'].submit()
}
function delete_profession(id)
{
	window.location.href = '/delete_pro?id=' + id;
}
function edit_profession(id)
{
	window.location.href = '/profession?id=' + id;
}
</script>
{% endblock %}

{% block content %}
	{% if admin %}
	<form name="profession" method="POST">
		<table align="center">
			<tr>
				<td>Мэргэжил</td>
				<td><input type="text" name="ProfessionName" value="{{ chosen_profession.ProfessionName }}"></td>
				<td><input type="button" value="Хадгалах" onclick="saveProfession()"></td>
			</tr>
			<table align="center">
				{% for profession in profession_list %}
				<tr>
					<td bgcolor="#AFC7C7">{{ profession.ProfessionName }}</td>
					<td>
						<input type="button" value="Засах" onclick="edit_profession({{ profession.key.id }})"/>
						<input type="button" value="Устгах" onclick="delete_profession({{ profession.key.id }})"/>
						<input type="hidden" name="chosen_profession" value="{{ chosen_profession.key.id }}" />
					</td>
				</tr>
				{% endfor %}
			</table>
		</table>
	</form>
	{% endif %}
{% endblock %}

{% block adminSlidebar %}{% include "adminSlidebar.html" %}{% endblock %}